<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 11] The java.io Package</TITLE>
<META NAME="author" CONTENT="Mark Grand and Jonathan Knudsen">
<META NAME="date" CONTENT="Fri Aug  8 16:33:07 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java Fundamental Classes Reference">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">
<script language='JavaScript'>
<!--
if (location.replace) {
 location.replace ('ch11_js.htm');
}
// -->
</script>

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java Fundamental Classes Reference" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch10_06.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 11</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch11_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<H1 CLASS=chapter><A CLASS="TITLE" NAME="JFC-CH-11">11. The java.io Package</A></H1>

<DIV CLASS=htmltoc>

<p>
<b>Contents:</b><br>
<a href='ch11_02.htm'>BufferedOutputStream</a><br>
<a href='ch11_03.htm'>BufferedReader</a><br>
<a href='ch11_04.htm'>BufferedWriter</a><br>
<a href='ch11_05.htm'>ByteArrayInputStream</a><br>
<a href='ch11_06.htm'>ByteArrayOutputStream</a><br>
<a href='ch11_07.htm'>CharArrayReader</a><br>
<a href='ch11_08.htm'>CharArrayWriter</a><br>
<a href='ch11_09.htm'>CharConversionException</a><br>
<a href='ch11_10.htm'>DataInput</a><br>
<a href='ch11_11.htm'>DataInputStream</a><br>
<a href='ch11_12.htm'>DataOutput</a><br>
<a href='ch11_13.htm'>DataOutputStream</a><br>
<a href='ch11_14.htm'>EOFException</a><br>
<a href='ch11_15.htm'>Externalizable</a><br>
<a href='ch11_16.htm'>File</a><br>
<a href='ch11_17.htm'>FileDescriptor</a><br>
<a href='ch11_18.htm'>FileInputStream</a><br>
<a href='ch11_19.htm'>FilenameFilter</a><br>
<a href='ch11_20.htm'>FileNotFoundException</a><br>
<a href='ch11_21.htm'>FileOutputStream</a><br>
<a href='ch11_22.htm'>FileReader</a><br>
<a href='ch11_23.htm'>FileWriter</a><br>
<a href='ch11_24.htm'>FilterInputStream</a><br>
<a href='ch11_25.htm'>FilterOutputStream</a><br>
<a href='ch11_26.htm'>FilterReader</a><br>
<a href='ch11_27.htm'>FilterWriter</a><br>
<a href='ch11_28.htm'>InputStream</a><br>
<a href='ch11_29.htm'>InputStreamReader</a><br>
<a href='ch11_30.htm'>InterruptedIOException</a><br>
<a href='ch11_31.htm'>InvalidClassException</a><br>
<a href='ch11_32.htm'>InvalidObjectException</a><br>
<a href='ch11_33.htm'>IOException</a><br>
<a href='ch11_34.htm'>LineNumberInputStream</a><br>
<a href='ch11_35.htm'>LineNumberReader</a><br>
<a href='ch11_36.htm'>NotActiveException</a><br>
<a href='ch11_37.htm'>NotSerializableException</a><br>
<a href='ch11_38.htm'>ObjectInput</a><br>
<a href='ch11_39.htm'>ObjectInputStream</a><br>
<a href='ch11_40.htm'>ObjectInputValidation</a><br>
<a href='ch11_41.htm'>ObjectOutput</a><br>
<a href='ch11_42.htm'>ObjectOutputStream</a><br>
<a href='ch11_43.htm'>ObjectStreamClass</a><br>
<a href='ch11_44.htm'>ObjectStreamException</a><br>
<a href='ch11_45.htm'>OptionalDataException</a><br>
<a href='ch11_46.htm'>OutputStream</a><br>
<a href='ch11_47.htm'>OutputStreamWriter</a><br>
<a href='ch11_48.htm'>PipedInputStream</a><br>
<a href='ch11_49.htm'>PipedOutputStream</a><br>
<a href='ch11_50.htm'>PipedReader</a><br>
<a href='ch11_51.htm'>PipedWriter</a><br>
<a href='ch11_52.htm'>PrintStream</a><br>
<a href='ch11_53.htm'>PrintWriter</a><br>
<a href='ch11_54.htm'>PushbackInputStream</a><br>
<a href='ch11_55.htm'>PushbackReader</a><br>
<a href='ch11_56.htm'>RandomAccessFile</a><br>
<a href='ch11_57.htm'>Reader</a><br>
<a href='ch11_58.htm'>SequenceInputStream</a><br>
<a href='ch11_59.htm'>Serializable</a><br>
<a href='ch11_60.htm'>StreamCorruptedException</a><br>
<a href='ch11_61.htm'>StreamTokenizer</a><br>
<a href='ch11_62.htm'>StringBufferInputStream</a><br>
<a href='ch11_63.htm'>StringReader</a><br>
<a href='ch11_64.htm'>StringWriter</a><br>
<a href='ch11_65.htm'>SyncFailedException</a><br>
<a href='ch11_66.htm'>UnsupportedEncodingException</a><br>
<a href='ch11_67.htm'>UTFDataFormatException</a><br>
<a href='ch11_68.htm'>WriteAbortedException</a><br>
<a href='ch11_69.htm'>Writer</a><br>
<p>
<p>
</DIV>

<P CLASS=para>
The package <tt CLASS=literal>java.io</tt> contains the 
classes that handle fundamental input and output operations
in Java.  The I/O classes can be grouped as follows:

<P>
<UL CLASS=itemizedlist>
<li CLASS=listitem>Classes for reading input from a stream of data.

<P>
<li CLASS=listitem>Classes for writing output to a stream of data.

<P>
<li CLASS=listitem>Classes that manipulate files on the local filesystem.

<P>
<li CLASS=listitem>Classes that handle object serialization.

<P>
</UL>
<P CLASS=para>
I/O in Java is based on streams.  A stream represents
a flow of data or a channel of communication.  Java 1.0 supports only
byte streams.  The <tt CLASS=literal>InputStream</tt> class is
the superclass of all of the Java 1.0 byte input streams, while 
<tt CLASS=literal>OutputStream</tt> is the superclass of all 
the byte output streams.  The drawback to these byte streams is
that they do not always handle Unicode characters correctly.  

<P CLASS=para>
As of Java 1.1, <tt CLASS=literal>java.io</tt> contains classes 
that represent character streams.  These character stream classes
handle Unicode characters appropriately by using a character encoding
to convert bytes to characters and vice versa.  The 
<tt CLASS=literal>Reader</tt> class is the superclass of all the Java
1.1 character input streams, while <tt CLASS=literal>Writer</tt>
is the superclass of all character output streams.

<P CLASS=para>
The <tt CLASS=literal>InputStreamReader</tt> and 
<tt CLASS=literal>OutputStreamWriter</tt> classes provide a bridge
between byte streams and character streams.  If you wrap an
<tt CLASS=literal>InputStreamReader</tt> around an
<tt CLASS=literal>InputStream</tt> object, the bytes in the byte
stream are read and converted to characters using the character
encoding scheme specified by the <tt CLASS=literal>InputStreamReader</tt>.
Likewise, you can wrap an <tt CLASS=literal>OutputStreamWriter</tt>
around any <tt CLASS=literal>OutputStream</tt> object so that you can 
write characters and have them converted to bytes.

<P CLASS=para>
As of Java 1.1, <tt CLASS=literal>java.io</tt> also contains
classes to support object serialization.  Object
serialization is the ability to write the complete state of
an object to an output stream, and then later recreate that
object by reading in the serialized state from an input stream.
The <tt CLASS=literal>ObjectOutputStream</tt> and
<tt CLASS=literal>ObjectInputStream</tt> classes handle serializing
and deserializing objects, respectively.

<P CLASS=para>
The <tt CLASS=literal>RandomAccessFile</tt> class is the only
class that does not use a stream for reading or writing data.
As its name implies, <tt CLASS=literal>RandomAccessFile</tt>
provides nonsequential access to a file for both reading
and writing purposes.  

<P CLASS=para>
The <tt CLASS=literal>File</tt> class represents a file on the
local file system.  The class provides methods to identify and 
retrieve information about a file.

<P CLASS=para>
<A HREF="ch11_01.htm#JFC-CH-11-FIG-1">Figure 11.1</A> shows the class hierarchy for the
<tt CLASS=literal>java.io</tt> package. The <tt CLASS=literal>java.io</tt>
package defines a number of standard I/O exception classes.  These
exception classes are all subclasses of
<tt CLASS=literal>IOException</tt>, as shown in <A HREF="ch11_01.htm#JFC-CH-11-FIG-2">Figure 11.2</A>.

<DIV CLASS=figure>
<h4 CLASS=figure><A CLASS="TITLE" NAME="JFC-CH-11-FIG-1">Figure 11.1: The java.io package</A></h4>


<p>
<img align=middle src="./figs/jfc_1101.gif" alt="[Graphic: Figure 11-1]" width=502 height=703 border=0>

</DIV>

<DIV CLASS=figure>
<h4 CLASS=figure><A CLASS="TITLE" NAME="JFC-CH-11-FIG-2">Figure 11.2: The exception classes in the java.io package</A></h4>


<p>
<img align=middle src="./figs/jfc_1102.gif" alt="[Graphic: Figure 11-2]" width=502 height=314 border=0>

</DIV>

<DIV CLASS=refnamediv>
<H1>BufferedInputStream</H1>

<H2>Name</H2>

BufferedInputStream

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.1">Synopsis</A></h2>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Class Name:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.io.BufferedInputStream</tt>

<p>
<DT CLASS=varlistentry>Superclass:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.io.FilterInputStream</tt>

<p>
<DT CLASS=varlistentry>Immediate Subclasses:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Interfaces Implemented:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Availability:<br>
<DD>

<P CLASS=para>
JDK 1.0 or later</DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.2">Description</A></h2>

<P CLASS=para>
A <tt CLASS=literal>BufferedInputStream</tt> object provides a more
efficient way to read just a few bytes at a time from an
<tt CLASS=literal>InputStream</tt>.
<tt CLASS=literal>BufferedInputStream</tt> object use a buffer to
store input from an associated <tt CLASS=literal>InputStream</tt>.  In
other words, a large number of bytes are read from the underlying
stream and stored in an internal buffer. A
<tt CLASS=literal>BufferedInputStream</tt> is more efficient than a
regular <tt CLASS=literal>InputStream</tt> because reading data from
memory is faster than reading it from a disk or a network. All reading
is done directly from the internal buffer; the disk or network
needs to be accessed only occasionally to fill up the buffer.

<P CLASS=para>
You should wrap a <tt CLASS=literal>BufferedInputStream</tt> 
around any <tt CLASS=literal>InputStream</tt> whose 
<tt CLASS=literal>read()</tt> operations may be time 
consuming or costly, such as a <tt CLASS=literal>FileInputStream</tt>. 

<P CLASS=para>
<tt CLASS=literal>BufferedInputStream</tt> provides 
a way to mark a position in the stream and subsequently reset the stream 
to that position, using <tt CLASS=literal>mark()</tt> 
and <tt CLASS=literal>reset()</tt>. 

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.3">Class Summary</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public class java.io.BufferedInputStream extends java.io.FilterInputStream {
  // Variables
  protected byte[] buf;
  protected int count;
  protected int marklimit;
  protected int markpos;
  protected int pos;
  // Constructors
  public BufferedInputStream(InputStream in);
  public BufferedInputStream(InputStream in, int size);
  // Instance Methods
  public synchronized int available();
  public synchronized void mark(int readlimit);
  public boolean markSupported();
  public synchronized int read();
  public synchronized int read(byte[] b, int off, int len);
  public synchronized void reset();
  public synchronized long skip(long n);
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.4">Variables</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.1">buf</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.1">protected byte[] buf</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The buffer that stores the data from the input stream. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.2">count</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.2">protected int count</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
A placeholder that marks the end of valid data in the buffer. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.3">marklimit</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.3">protected int marklimit</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The maximum number of bytes that can be read after a call to <tt CLASS=literal>mark()</tt> 
before a call to <tt CLASS=literal>reset()</tt> fails. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.4">markpos</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.4">protected int markpos</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The position of the stream when <tt CLASS=literal>mark()</tt> 
was called. If <tt CLASS=literal>mark()</tt> has not 
been called, this variable is <tt CLASS=literal>-1</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.5">pos</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.5">protected int pos</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The current position in the buffer, or in other words, the index of the 
next character to be read. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.5">Constructors</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.6">BufferedInputStream</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.6">public BufferedInputStream(InputStream in)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>in</tt><br>
<DD>

<P CLASS=para>
The input stream to buffer. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This constructor creates a <tt CLASS=literal>BufferedInputStream</tt> 
that buffers input from the given <tt CLASS=literal>InputStream</tt>, 
using a buffer with the default size of 2048 bytes. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.7">public BufferedInputStream(InputStream in, int size)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>in</tt><br>
<DD>

<P CLASS=para>
The input stream to buffer.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>size</tt><br>
<DD>

<P CLASS=para>
The size of buffer to use. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This constructor creates a <tt CLASS=literal>BufferedInputStream</tt> 
that buffers input from the given <tt CLASS=literal>InputStream</tt>, 
using a buffer of the given size. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.6">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.7">available</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.8">public synchronized int available() throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The number of bytes that can be read without blocking. 

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt> <br>
<DD>

<P CLASS=para>
If any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>FilterInputStream.available()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the number of bytes that can be read without having 
to wait for more data to become available. The returned value is the sum 
of the number of bytes remaining in the object's buffer and the number 
returned as the result of calling the <tt CLASS=literal>available()</tt> 
method of the underlying <tt CLASS=literal>InputStream</tt> 
object. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.8">mark</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.9">public synchronized void mark(int readlimit)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>readlimit</tt><br>
<DD>

<P CLASS=para>
The maximum number 
of bytes that can be read before the saved position becomes invalid. </DL>
<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>FilterInputStream.mark()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method causes the <tt CLASS=literal>BufferedInputStream</tt> 
to remember its current position. A subsequent call to <tt CLASS=literal>reset()</tt> 
causes the object to return to that saved position, and thus reread a 
portion of the buffer. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.9">markSupported</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.10">public synchronized boolean markSupported()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>boolean</tt> value <tt CLASS=literal>true</tt>. 

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>FilterInputStream.markSupported()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns <tt CLASS=literal>true</tt> to 
indicate that this class supports <tt CLASS=literal>mark()</tt> 
and <tt CLASS=literal>reset()</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.10">read</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.11">public synchronized int read() throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The next byte of data or <tt CLASS=literal>-1</tt> if the end of the stream is encountered. 

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>FilterInputStream.read()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the next byte from the buffer. If all the bytes in 
the buffer have been read, the buffer is filled from the underlying <tt CLASS=literal>InputStream</tt> 
and the next byte is returned. If the buffer does not need to be filled, 
this method returns immediately. If the buffer needs to be filled, this 

method blocks until data is available from the underlying <tt CLASS=literal>InputStream</tt>, 
the end of the stream is reached, or an exception is thrown. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.12"><DIV CLASS=screen> <P> <PRE> public synchronized int read(byte b[], int off, int len) throws IOException </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>b</tt><br>
<DD>

<P CLASS=para>
An array of bytes to 
be filled from the stream.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>off</tt><br>
<DD>

<P CLASS=para>
An offset into the 
byte array.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>len</tt><br>
<DD>

<P CLASS=para>
The number of bytes 
to read. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The actual number of bytes read or <tt CLASS=literal>-1</tt> if the end of the stream is encountered 
immediately. 

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>FilterInputStream.read(byte[], int, int)</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method copies bytes from the internal buffer into the given array 
<tt CLASS=literal>b</tt>, starting at index <tt CLASS=literal>off</tt> 
and continuing for up to <tt CLASS=literal>len</tt> bytes. 
If there are any bytes in the buffer, this method returns 
immediately. Otherwise the buffer needs to be filled; this method
blocks until the data is available from the underlying <tt CLASS=literal>InputStream</tt>, 
the end of the stream is reached, or an exception is thrown. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.11">reset</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.13">public synchronized void reset() throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If there was 
no previous call to this <tt CLASS=literal>BufferedInputStream</tt>'s 
mark method, or the saved position has been invalidated. </DL>
<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>FilterInputStream.reset()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method sets the position of the <tt CLASS=literal>BufferedInputStream</tt> 
to a position that was saved by a previous call to <tt CLASS=literal>mark()</tt>. 
Subsequent bytes read from this <tt CLASS=literal>BufferedInputStream</tt> 
will begin from the saved position and continue normally. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.12">skip</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.14">public synchronized long skip(long n) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>n</tt><br>
<DD>

<P CLASS=para>
The number of bytes to skip. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The actual number of bytes skipped. 

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>FilterInputStream.skip()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method skips <tt CLASS=literal>n</tt> bytes of 
input. If the new position of the stream is still within the data contained 
in the buffer, the method returns immediately. Otherwise the <tt CLASS=literal>skip()</tt> 
method of the underlying stream is called. A subsequent call to <tt CLASS=literal>read()</tt> 
forces the buffer to be filled. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.7">Inherited Methods</A></h2>

<DIV CLASS=informaltable>
<P>
<TABLE CLASS=INFORMALTABLE>
<TR CLASS=row>
<TH ALIGN="LEFT">

<P CLASS=para>
Method</TH>
<TH ALIGN="LEFT">

<P CLASS=para>
Inherited From</TH>
<TH ALIGN="LEFT">

<P CLASS=para>
Method</TH>
<TH ALIGN="LEFT">

<P CLASS=para>
Inherited From</TH>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>clone()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>close()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>FilterInputStream</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>equals(Object)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>finalize()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>getClass()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>hashCode()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>notify()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>notifyAll()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>read(byte[])</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>FilterInputStream</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>toString()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>void wait()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>void wait(long)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>void wait(long, int)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">&nbsp;</TD>
<TD ALIGN="LEFT">&nbsp;</TD>
</TR>
</TABLE>
<P>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.8">See Also</A></h2>

<P CLASS=para>
<tt CLASS=literal>FilterInputStream</tt>, 
<tt CLASS=literal>InputStream</tt>, 
<tt CLASS=literal>IOException</tt> 
</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch11_69.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch11_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>Writer</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>BufferedOutputStream</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
